unit DUnitX.BaseExecutive;
interface
uses MLC.UnitTestFramework, Classes, SBD.ServiceProvider;

type

IExecutive = interface
  ['{45B82A12-5F95-4515-BFE6-CE54799E4E2F}']
    procedure StartUp;
    procedure ShutDown;
    function  Model: IUnitTestingEngine;
    procedure DeclareMainForm( MainForm: TComponent);
    function  Services: IServiceProvider;
    procedure RegisterTestFixtures;
    function  ApplicationTitle: string;
  end;

TBaseExecutive = class( TInterfacedObject, IExecutive)
  private
    FMainForm: TComponent;

    procedure StartUp;
    procedure ShutDown;
    function  Model: IUnitTestingEngine;
    procedure DeclareMainForm( MainForm: TComponent);
    function  Services: IServiceProvider;

  protected
    FServices: IServiceProvider;
    FModel: IUnitTestingEngine;

    function  ApplicationTitle: string;                   virtual; abstract;
    procedure RegisterTestFixtures;                       virtual; abstract;
    procedure RegisterServices;                           virtual;
  public
    constructor Create;
    destructor Destroy; override;
  end;


implementation







uses MLC.UnitTestFramework.Solution, MLC.MemoryMonitor.Solution,
     DUnitX.Fixture, DUnitX.TestProcedure;


constructor TBaseExecutive.Create;
begin
FServices := StandardServiceProvider;
RegisterServices;
FServices.Gn.Acquire<IUnitTestingEngine>( nil, FModel)
end;

procedure TBaseExecutive.DeclareMainForm( MainForm: TComponent);
begin
FMainForm := MainForm
end;

destructor TBaseExecutive.Destroy;
begin
ShutDown;
inherited
end;

function TBaseExecutive.Model: IUnitTestingEngine;
begin
result := FModel
end;



procedure TBaseExecutive.RegisterServices;
begin
MLC.UnitTestFramework.Solution.RegisterServices( FServices);
MLC.MemoryMonitor.Solution    .RegisterServices( FServices);
DUnitX.Fixture                .RegisterServices( FServices);
DUnitX.TestProcedure          .RegisterServices( FServices);

end;

function TBaseExecutive.Services: IServiceProvider;
begin
result := FServices
end;

procedure TBaseExecutive.ShutDown;
begin
if assigned( FServices) then
  begin
  FServices.ShutDown;
  FServices := nil
  end;
if assigned( FModel) then
  begin
  FModel.Shutdown;
  FModel    := nil
  end
end;

procedure TBaseExecutive.StartUp;
begin
end;



end.
